﻿@model ShopKart.Areas.User.Models.ProductVm

@{
    ViewBag.Title = "Product Detail";
    Layout = "~/Areas/User/Views/Shared/_UserLayout.cshtml";
}


<div class="page-content-wrapper">
    <div class="page-content">
        <div class="row">
            <div class="col-md-4">
                <img class="img-square img-responsive" src="~/UploadedFiles/@Model.Image" />
            </div>
            <div class="col-md-7">
                <div class="row">
                    <h2>@Model.ProductName </h2> <h4>in Category @Model.Category.CategoryName</h4>
                </div>
                <div class="row">
                    <h3>@Model.Weight</h3>
                </div>
                <div class="row">
                    <h3>@Model.Price</h3>
                </div>
                <div class="row">
                    <h3>@Model.Description</h3>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-5">
                <button type="submit" class="btn green btnAddProductToCart ladda-button formSaveButton pull-right" data-style="zoom-in">
                    <span class="ladda-label">Add To Cart</span>
                </button>
            </div>
        </div>
    </div>
</div>


@section scripts{

    <script>
        $(function () {
            $('.btnAddProductToCart').on('click', function () {
                var productId = $(this).data('id');

                var UserCart = {
                    ProductId: productId
                }

                $('.btnAddProductToCart').skartAjax({
                    url: '@Url.Action("AddProductToCart", "Common", new {area = "User"})',
                    method: "POST",
                    data: JSON.stringify(UserCart),
                    processData: false,
                    loaderButtonSelector: '#btnAddProductToCart_' + productId,
                    contentType: "application/json; charset=utf-8",
                    success: function (data, textStatus, jqXhr) {
                        LoadUserCart();
                        StopButtonLoading('#btnAddProductToCart_' + productId);
                    }
                });
            });
        });
    </script>
}

